﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CardInChina.Data.Entity.Entity;

namespace CardInChina.Data.Entity.Interface
{
    public class ExchangeService
    {
        public double GetExchangeValueFromRMB(double orignalValue, int currency_type)
        {
            using (CICEntities db = new CICEntities())
            {
                var exchange = db.Exchanges.First(p => p.ID == currency_type);
                return orignalValue / exchange.Rate;
 
            }
        }

        public Exchange GetExchangeEntityByExchangeID(int id)
        {
            using (CICEntities db = new CICEntities())
            {
                return db.Exchanges.First(e => e.ID == id);
            }
        }
    }
}
